﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Peak.Core;
using Peak.Resources;

namespace Peak.Web.Controllers.Models
{
  public class DashboardItem
  {
    public string Name { get; set; }
    public DashboardItemType Type { get; set; }       
    public int Id { get; set; }
    public string Status{ get; set;}
    public Story Story{ get; set;}
    public User AssignedTo{ get; set;}
    public TimeSpan RemainingEffort { get; set; }
    public string Path { get; set; }
    public string Category { get; set; }

    public DashboardItem(Task task, bool onlyFromCurrentSprint)
    {
      Id = task.Id;
      Type = DashboardItemType.Task;
      Name = task.Name;
      Story = task.SprintStory.Story;
      Status = Statuses.ResourceManager.GetString(task.Status.ToString());
      AssignedTo = task.AssignedTo;
      RemainingEffort = task.RemainingEffort;
      if (task.SprintStory.Story != null)
      {
        if (task.SprintStory.Sprint != null)
        {
          if(!onlyFromCurrentSprint)
          {
            Path = task.SprintStory.Sprint.Name + "\\";
          }
          
          Path+= task.SprintStory.Story.Name;          
        }
        else
        {
          Path = Labels.Backlog + "\\" + task.SprintStory.Story.Name;
        }
      }
      Category = task.Category;
    }   
  }
}
